<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Zookeeper 集群监控指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .metric-card {
            background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
            border-left: 4px solid #667eea;
        }
        
        .tool-card {
            background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
            color: #2d3436;
        }
        
        .best-practice-card {
            background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
            color: #2d3436;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
            padding-bottom: 10px;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 3px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .code-block {
            background: #2d3436;
            color: #74b9ff;
            padding: 20px;
            border-radius: 10px;
            font-family: 'Courier New', monospace;
            position: relative;
            overflow-x: auto;
        }
        
        .code-block::before {
            content: 'Shell';
            position: absolute;
            top: 10px;
            right: 10px;
            color: #636e72;
            font-size: 12px;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.6s ease-out;
        }
        
        .number-circle {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            flex-shrink: 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center animate-fadeInUp">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    <i class="fas fa-network-wired mr-4"></i>
                    Zookeeper 集群监控指南
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    掌握关键指标，确保分布式系统的高可用性与卓越性能
                </p>
                <div class="mt-8 flex justify-center space-x-4">
                    <div class="bg-white bg-opacity-20 rounded-full px-6 py-3">
                        <i class="fas fa-chart-line mr-2"></i>8 大核心指标
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-full px-6 py-3">
                        <i class="fas fa-tools mr-2"></i>7 种监控工具
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-full px-6 py-3">
                        <i class="fas fa-shield-alt mr-2"></i>最佳实践
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Introduction -->
    <div class="container mx-auto px-6 py-12">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-2xl shadow-xl p-8 animate-fadeInUp">
                <p class="text-lg leading-relaxed text-gray-700 indent-8">
                    监控 Zookeeper 集群的状态是确保其高可用性和性能的关键步骤。有效的监控可以帮助及时发现问题并采取措施，确保集群的稳定性。
                </p>
            </div>
        </div>
    </div>

    <!-- Monitoring Architecture Diagram -->
    <div class="container mx-auto px-6 py-12">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-sitemap mr-3 text-purple-600"></i>
                监控架构概览
            </h2>
            <div class="mermaid">
                graph TB
                    subgraph "Zookeeper 集群"
                        ZK1[Leader 节点]
                        ZK2[Follower 节点1]
                        ZK3[Follower 节点2]
                    end
                    
                    subgraph "监控指标"
                        M1[节点状态]
                        M2[延迟指标]
                        M3[吞吐量]
                        M4[连接数]
                        M5[资源使用]
                    end
                    
                    subgraph "监控工具"
                        T1[Prometheus]
                        T2[Grafana]
                        T3[ELK Stack]
                        T4[Zabbix]
                    end
                    
                    ZK1 --> M1
                    ZK2 --> M1
                    ZK3 --> M1
                    ZK1 --> M2
                    ZK1 --> M3
                    ZK1 --> M4
                    ZK1 --> M5
                    
                    M1 --> T1
                    M2 --> T1
                    M3 --> T1
                    M4 --> T1
                    M5 --> T1
                    T1 --> T2
                    
                    style ZK1 fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style T2 fill:#48bb78,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>
    </div>

    <!-- Monitoring Metrics -->
    <div class="container mx-auto px-6 py-12">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-tachometer-alt mr-3 text-purple-600"></i>
                常用的监控指标
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- 节点状态 -->
                <div class="metric-card rounded-xl p-6 card-hover">
                    <div class="flex items-start">
                        <div class="number-circle">1</div>
                        <div class="ml-4 flex-1">
                            <h3 class="text-xl font-bold text-gray-800 mb-3">节点状态</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-crown text-yellow-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>Leader 状态：</strong>检查当前的 Leader 节点，确保集群中只有一个 Leader。
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-users text-blue-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>Follower 状态：</strong>检查 Follower 节点的状态，确保它们能够与 Leader 节点同步。
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 延迟指标 -->
                <div class="metric-card rounded-xl p-6 card-hover">
                    <div class="flex items-start">
                        <div class="number-circle">2</div>
                        <div class="ml-4 flex-1">
                            <h3 class="text-xl font-bold text-gray-800 mb-3">延迟指标</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-clock text-orange-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>请求延迟：</strong>测量请求从客户端到 Zookeeper 服务器的平均延迟。高延迟可能表明网络问题或服务器负载过高。
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-stopwatch text-red-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>响应时间：</strong>监控 Zookeeper 对客户端请求的响应时间。
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 吞吐量 -->
                <div class="metric-card rounded-xl p-6 card-hover">
                    <div class="flex items-start">
                        <div class="number-circle">3</div>
                        <div class="ml-4 flex-1">
                            <h3 class="text-xl font-bold text-gray-800 mb-3">吞吐量</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-exchange-alt text-green-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>请求数：</strong>每秒的请求数量，包括读请求和写请求。
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-chart-line text-purple-500 mt-1 mr-2"></i>
                                    <div>
                                        <strong>数据变化率：</strong>数据在 Zookeeper 中的变化频率，如节点的创建、删除和更新操作。
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 连接数 -->
                <div class="metric-card rounded-xl p-6 card-hover">
                    <div class="flex items-start">
                        <div class="number-circle">4</div>
                        <div class="ml-4 flex-1">
                            <h3 class="text-xl font-bold text-gray-800 mb-3">连接数</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-link text-blue-600 mt-1 mr-2"></i>
                                    <div>
                                        <strong>活跃连接数：</strong>当前活跃的客户端连接数。
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-exclamation-triangle text-yellow-600 mt-1 mr-2"></i>
                                    <div>
                                        <strong>连接数限制：</strong>监控当前连接数是否接近最大限制，以避免连接超限。
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 磁盘使用 -->
                <div class="metric-card rounded-xl p-6 card-hover">
                    <div class="flex items-start">
                        <div class="number-circle">5</div>
                        <div class="ml-4 flex-1">
                            <h3 class="text-xl font-bold text-gray-800 mb-3">磁盘使用</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-hdd text-gray-600 mt-1 mr-2"></i>
                                    <div>
                                        <strong>磁盘空间：</strong>Zookeeper 的数据目录使用的磁盘空间。
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-sync text-indigo-600 mt-1 mr-2"></i>
                                    <div>
                                        <strong>磁盘 I/O：</strong>磁盘读写操作的性能